package com.cx.dbtablelist.excel;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;


public abstract class ExcelUtils {
	
	/**
	 * 读取一个excel文件
	 * @author caoxu-yiyang@qq.com
	 * @param fileName
	 * @throws IOException 
	 */
	public static Workbook readFile(String readFileName) throws IOException{
		FileInputStream fileInputStream = new FileInputStream(readFileName);
		Workbook workbook = new HSSFWorkbook(fileInputStream);
		return workbook;
	}
	
	/**
	 * 写入一个excel文件
	 * @author caoxu-yiyang@qq.com
	 * @param workbook
	 * @param writeFileName
	 * @throws IOException
	 */
	public static void writeFile(Workbook workbook, String writeFileName) throws IOException{
		FileOutputStream fileOutputStream = new FileOutputStream(writeFileName);
		workbook.write(fileOutputStream);
		fileOutputStream.close();
	}
}
